package cn.starlightsoftware.sherly.controller.admin.tenant;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import cn.starlightsoftware.sherly.controller.admin.tenant.vo.TenantSaveReqVO;
import cn.starlightsoftware.sherly.model.Result;
import cn.starlightsoftware.sherly.service.tenant.TenantService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.starlightsoftware.sherly.model.Result.success;

/**
 * @author 谷子毅
 */
@Validated
@Tag(name = "admin-租户")
@RestController
@RequestMapping("/system/tenant")
public class TenantController {

    @Resource
    private TenantService tenantService;

    @PostMapping("/save")
    @PreAuthorize("@ss.hasAnyScopes('system:tenant:save')")
    @Operation(summary = "租户新增")
    public Result<?> save(@Valid @RequestBody TenantSaveReqVO reqVO) {
        tenantService.save(reqVO);
        return success();
    }


}
